/*            Copyright(c) 2006-2008 Dave Sexton           *
 * http://www.codeplex.com/DocProject                      *
 * http://www.codeplex.com/DocProject/Project/License.aspx *
 ***********************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.XPath;

namespace DaveSexton.DocProject.Sandcastle.ContentManagement
{
	[Serializable]
	public class XmlContentItem : ContentItem
	{
		public override string Value
		{
			get
			{
				if (IsValueDesignable)
					return navigator.InnerXml;
				else
					return navigator.Value;
			}
			set
			{
				if (IsValueDesignable)
					navigator.InnerXml = value;
				else
					navigator.SetValue(value);

				IsDirty = true;
			}
		}

		public XPathNavigator Navigator { get { return navigator; } }

		[NonSerialized]
		private readonly XPathNavigator navigator;

		public XmlContentItem(IXPathNavigable node, string name, bool designable)
			: base(name, designable)
		{
			if (node == null)
				throw new ArgumentNullException("node");

			navigator = node.CreateNavigator();
		}
	}
}
